layui.use(['layer','form','table','element','layedit','upload','laydate'],function () {
    var layer = layui.layer
        ,form = layui.form
        ,table =layui.table
        ,element = layui.element
        ,layedit = layui.layedit
        ,upload = layui.upload
        ,laydate = layui.laydate;

    var projectId = $("#projectId").val();

        //提交表单
    form.on('submit(form)',function (data) {
        layer.msg('保存中...', { icon: 16, shade: [0.5, '#f5f5f5'], scrollbar: false, offset: '50%', time: 300000 });

        //校验类型和标签是否选择
        // var label_length = $("input[name=label]:checked").length;
        // var type_length = $("input[name=type]:checked").length;

        var paramData = {
            "qq":$("#qq").val(),
            "phone":$("#phone").val(),
            "projectId":projectId
        };

        var data2 = JSON.stringify(paramData);

        //保存项目
        $.ajax({
            url:"/admin/guaranteeProject/project_user_save",
            type:"POST",
            data:data2,
            // dataType:"json",
            contentType:"application/json;charset=utf-8",
            success:function (result) {
                // console.log("data=="+form_data)
                if(result.flag){
                    layer.msg(result.message);
                    //清空内容
                    // $("#form").reset();
                    document.getElementById("form").reset();
                    layui.form.render();
                }else{
                    layer.msg(result.message);
                }
            },
            error:function () {
                layer.msg("系统错误！");
            }
        });

    });

    // layedit.setContent(index, "<h1 style='color: red'>hahahha</h1>");

    // $('#submitBtn').click(function () {
    //     //获取编辑器的值
    //     var content = layedit.getContent(index);
    //
    //     alert(content);
    // });


});


// 设置最小可选的日期
function minDate(){
    var now = new Date();
    return now.getFullYear()+"-" + (now.getMonth()+1) + "-" + (now.getDate()+1);
}